var arr = [3, 5, 7, 1, 4, 56, 12, 78, 25, 0, 9, 3, 8, 42, 37];

console.time('time')
function insertionSort(arr) {
  for (let i = 1; i < arr.length; i++) {
    let key = i;
    while (arr[key - 1] > arr[key]) {
      var val = arr[key];
      arr[key] = arr[key - 1];
      arr[key - 1] = val;
      key--;
    }
  }
  return arr;
}

console.log(insertionSort(arr));
console.timeEnd('time')
